package cc.example;

import reactor.core.publisher.Flux;

public class 常用api {
    Flux<Integer> just = Flux.just(1, 2, 3, 4, 5);

    public static void main(String[] args) {
        Flux<String> flux = Flux.fromArray(new String[]{"1", "a", "b"})
                .log();

        flux.subscribe();


        Flux<Integer> range = Flux.range(1, 2);
        range
                //transform 无defer，不会共享外部变量的值。无状态转换
                //transform 有defer，会共享外部变量的值。有状态转换
                .transform(integerFlux -> {
                    return  Flux.range(1,2);
                })
                .log()
                .subscribe();



        Flux.empty() // 如果发布者元素为nULl，指定默认值，否则用发布者的值
                .defaultIfEmpty(1);

        Flux.empty()
                .switchIfEmpty( Flux.range(1, 2));


//        Flux.range(1,10)
//                .zipWith()


    }
}
